package cn.ondraw.ragflow.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import cn.ondraw.common.core.domain.R;
import cn.ondraw.ragflow.pojo.request.*;
import cn.ondraw.ragflow.pojo.request.RetrieveTestChunksRequest;
import cn.ondraw.ragflow.service.ChunkService;
import org.springframework.web.bind.annotation.*;

/**
 * 知识块
 */
@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/v1")
public class RagFlowChunkController {
    private final ChunkService chunkService;


    /**
     * 测试检索块
     *
     * @param request 检索块的请求对象
     * @return 检索块的响应对象
     */
    @PostMapping("/chunk/retrieval_test")
    public R<Object> chunksRetrieveTest(@RequestBody RetrieveTestChunksRequest request) {
        try {
            return R.ok(chunkService.chunksRetrieveTest(request));
        } catch (Exception e) {
            return R.fail(e.getMessage());
        }
    }
}
